package com.zp.base.admin.listener;

import lombok.extern.slf4j.Slf4j;

import javax.servlet.annotation.WebListener;
import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;

/**
 * @author ZhangPeng
 * @email zhangpeng98@aliyun.com
 * @create 2021-03-07 16:43
 */
@WebListener
@Slf4j
public class SessionListener implements HttpSessionListener {

    public static int onlineUserTotal = 0;

    @Override
    public void sessionCreated(HttpSessionEvent se) {
        log.info("session创建了..., 当前在线人数{}", ++onlineUserTotal);
    }

    @Override
    public void sessionDestroyed(HttpSessionEvent se) {
        log.info("session销毁了..., 当前在线人数{}", --onlineUserTotal);
    }
}
